package day01.pm;

import java.awt.*;

public class Demo02 {
    public static void main(String[] args) {
        Frame frame = new Frame();
        frame.setTitle("满天星");
        frame.setSize(1024,768);
        //设置窗体背景颜色为黑色
        frame.setBackground(Color.BLACK);
        StarPanel sp = new StarPanel();
        frame.add(sp);
        frame.show();
    }
}
class StarPanel extends Panel{
    @Override
    public void paint(Graphics g) {
        //设置字体颜色
//        g.setColor(Color.WHITE);

        //循环300次,在天空绘制300个星星
        for(int i=300;i>=1;i--){
            g.setColor(new Color((int)(Math.random()*255),
                    (int)(Math.random()*255),(int)(Math.random()*255)));
            //创建一个字体
            Font f = new Font("宋体",Font.BOLD,(int)(Math.random()*30));
            g.setFont(f);
            g.drawString("$",(int)(Math.random()*1024),
                    (int)(Math.random()*768));
        }
        g.setColor(Color.WHITE);
        g.fillOval(800,50,150,150);
        g.setColor(Color.BLACK);
        g.fillOval(820,30,150,150);
    }
}
